<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="结算组织">
              <a-input placeholder="请输入结算组织名称" v-model="queryParam.name" />
            </a-form-item>
          </a-col>
           <a-col :xl="6" :lg="7" :md="8" :sm="24">
             <a-form-item label="认证情况">
               <j-dict-select-tag placeholder="请选择认证情况" v-model="queryParam.authStatus" dictCode="finance_logistics_ec_auth_status"/>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
              <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'" />
              </a>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择
        <a style="font-weight: 600">{{ selectedRowKeys.length }}</a
        >项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        :scroll="{ x: true }"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
        class="j-table-force-nowrap"
        @change="handleTableChange"
        :customRow="selectRowData"
      >
        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px; font-style: italic">无图片</span>
          <img
            v-else
            :src="getImgView(text)"
            height="25px"
            alt=""
            style="max-width: 80px; font-size: 12px; font-style: italic"
            :preview="0"
          />
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px; font-style: italic">无文件</span>
          <a-button v-else :ghost="true" type="primary" icon="download" size="small" @click="downloadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>
          <span v-if="record.authStatus!=='0'">
          <a-divider type="vertical" />
          <a @click="handleDetails(record)">详情</a>
          </span>
        </span>
      </a-table>
    </div>

    <base-settlement-org-user-modal ref="modalForm" @ok="modalFormOk"></base-settlement-org-user-modal>
    <base-settlement-org-user-detail-modal ref="detailModal" @ok="modalFormOk"></base-settlement-org-user-detail-modal>
  </a-card>
</template>

<script>
import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import BaseSettlementOrgUserModal from './modules/BaseSettlementOrgUserModal'
import BaseSettlementOrgUserDetailModal from './modules/BaseSettlementOrgUserDetailModal'
import { filterMultiDictText } from '@/components/dict/JDictSelectUtil'

export default {
  name: 'BaseSettlementOrgUserList',
  mixins: [JeecgListMixin, mixinDevice],
  components: {
    BaseSettlementOrgUserModal,
    BaseSettlementOrgUserDetailModal,
  },
  data() {
    return {
      description: '结算组织用户映射表管理页面',
      // 表头
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function (t, r, index) {
            return parseInt(index) + 1
          },
        },
        {
          title: '组织名称',
          align: 'center',
          dataIndex: 'name',
        },
        {
          title: '账户余额',
          align: 'center',
          dataIndex: 'balance',
          sorter: true,
        },
        {
          title: '实际余额',
          align: 'center',
          dataIndex: 'realBalance',
        },
        {
          title: '临时额度',
          align: 'center',
          dataIndex: 'temporaryBalance',
        },
        {
          title: '7天平均费用',
          align: 'center',
          dataIndex: 'weekAverageAmount',
        },
        {
          title: '管理用户',
          align: 'center',
          dataIndex: 'users',
          sorter: true,
        },
         //=======================暂时隐藏开始   0826 ==================
         {
           title: '认证情况',
           align: 'center',
           dataIndex: 'authStatus_dictText',
           sorter: true,
           customCell: (record, rowIndex) => {                      
             //0 未认证  1审核中  2已认证  3认证失败
             if (record.authStatus =='0' ) {
               return { style: { color: '#f59a23' } }
             } else if (record.authStatus == '1') {
               return { style: { color: '#02a7f0' } }
             } else if (record.authStatus == '2') {
               return { style: { color: '#70b603' } }
             }else if (record.authStatus == '3') {
               return { style: { color: '#d9001b' } }
             }
           },
         },        
         {
           title: '操作',
           dataIndex: 'action',
           align: 'center',
           fixed: 'right',
           width: 147,
           scopedSlots: { customRender: 'action' },
         },
      //======================= 暂时隐藏结束   0826 ==================
      ],
      url: {
         list: '/finance/baseSettlementOrg/list/my',
      },
      dictOptions: {},
      superFieldList: [],
    }
  },
  created() {
    this.getSuperFieldList()
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    },
  },
  methods: {
    initDictConfig() {},
    selectRowData(record, index) {
      const that = this
      return {
        on: {
          dblclick: () => {
            this.handleDetail(record)
          },
        },
      }
    },
    handleDetails(record) {
      this.$refs.detailModal.edit(record)
      this.$refs.detailModal.title = '详情'
      this.$refs.detailModal.disableSubmit = true
    },
    getSuperFieldList() {
      let fieldList = []
      fieldList.push({
        type: 'sel_search',
        value: 'settlementOrgId',
        text: '结算组织id',
        dictTable: 'lg_base_settlement_org',
        dictText: 'name',
        dictCode: 'id',
      })
      fieldList.push({ type: 'list_multi', value: 'user', text: '用户名称', dictTable: '', dictText: '', dictCode: '' })
      this.superFieldList = fieldList
    },
  },
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>